package edu.sctu.practice.class02.xuejiahua.assign04;

import org.omg.CosNaming.NamingContextExtPackage.StringNameHelper;

/**
 * Created by Dom_xuejiahua on 2015/12/17.
 */
public class StringTest {
    public static void main(String[] args) {
        String str1 = new String("i am a super man");

        String str2 = new String("学前教育篇");//使用equals方法判断str1与str2是否相同


        if (str1.equals(str2)){
            System.out.println("str1与str2相同");
        }else{
            System.out.println("str1与str2不同");
        }

        String str3 = new String("332582545879654851254");

        //判断 str3的前缀是否是“33258”
        if (str3.startsWith("33258")) {
            System.out.println("那个啥省的身份证");

        }

        String str4 = new String("你");

        String str5 = new String("我");


        if (str4.compareTo(str5) > 0){

            System.out.println("按字典序str4大于str5");

        }else{
            System.out.println("按字典序str4小于str5");


        }

        int position = 0;
        String path = "C:\\java\\jsp\\A.java";

        //获取path中最后出现目录分隔符号的位置
        position = path.lastIndexOf("\\");
;
        System.out.println("c:\\java\\jsp\\A.java中最后出现\\的位置:" + position);

        String fileName = path.substring(12,path.length());//获取path中“A.java”子字符串。

        System.out.println("c:\\java\\jsp\\A.java中含有的文件名:"+fileName);

        String str6=new String("100");

        String str7=new String("123.678");

        int n1 = Integer.parseInt(str6);   //将str6转化成int型数据。

        double n2 = Double.parseDouble(str7);  //将str7转化成double型数据。

        double m=n1+n2;

        System.out.println(m);

        String str8 =String.valueOf(m); //String调用valuOf(int n)方法将m转化为字符串对象

        position = str8.indexOf(".");

        String temp = str8.substring(position+1);

        System.out.println("数字"+m+"有"+temp.length()+"位小数") ;

        String str9=new String("ABCDEF");

        char a[]= new char[str8.length()];//将str8存放在数组a中

        for(int i=a.length-1;i>=0;i--)
        {
            System.out.print(" "+a[i]);
        }


    }
}
